<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="./node_modules/jquery/dist/jquery.min.js"></script>
</head>

<body>
  <button id="btnGET">GET</button>
  <button id="btnPOST">POST</button>
  <button id="btnJSONP">JSONP</button>
  <button id="btnDELETE">DELETE</button>
  <script>
    $(function () {
      $('#btnGET').on('click', function () {
        $.ajax({
          type: 'GET',
          url: 'http://127.0.0.1:8080/api/get',
          data: {
            name: 'shuo',
            age: 18,
            gender: '男'
          },
          success: function (res) {
            console.log(res)
          }
        });
      })

      $('#btnPOST').on('click', function () {
        $.ajax({
          type: 'POST',
          url: 'http://127.0.0.1:8080/api/post',
          data: {
            bookname: '水浒传',
            author: '施耐庵'
          },
          success: function (res) {
            console.log(res)
          }
        });
      })

      $('#btnDELETE').on('click', function () {
        $.ajax({
          type: 'DELETE',
          url: 'http://127.0.0.1:8080/api/delete',
          success: function (res) {
            console.log(res)
          }
        });
      })

      $('#btnJSONP').on('click', function () {
        $.ajax({
          type: 'GET',
          url: 'http://127.0.0.1:8080/api/jsonp',
          dataType: 'jsonp',
          success: function (res) {
            console.log(res)
          }
        });
      })
    })
  </script>
</body>

</html>